<template>
  <div class="audio-deatail__module">
    <div class="audio-detail__wrapper">
      <img :src="cover" class="audio-bg__item" />
      <img :src="cover" class="audio-cover__item" />
      <div class="audio-info__group">
        <div class="audio-info__item audio-title__item" v-text="title" />
        <div class="audio-info__item audio-classify__group">
          <mivaLink class="item" to="/audio">音频</mivaLink>
          <template v-if="className">
            <i class="el-icon-arrow-right" />
            <mivaLink class="item" to="/audio">{{className}}</mivaLink>
          </template>
        </div>
        <div class="audio-info__item">{{createdAt | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</div>
        <div class="audio-info__item">
          <div :class="[{open:markShow }]" class="audio-mark__item">简介: {{mark}}</div>
          <div @click="markShow = !markShow" class="audio-mark-show__btn">{{markShowBtnText}}</div>
        </div>
      </div>
    </div>
    <resourceList :resources="resources" />
  </div>
</template>

<script>
import resourceList from './resourceList.vue';

export default {
    components: {
        resourceList,
    },
    props: {
        audioInfo: {
            type: Object,
            default: () => ({}),
        },
    },
    data() {
        return {
            markShow: false,
        };
    },
    computed: {
        cover() {
            return this.audioInfo.cover;
        },
        title() {
            return this.audioInfo.title || '没有标题';
        },
        className() {
            return this.audioInfo.className || '';
        },
        createdAt() {
            return this.audioInfo.created_at || new Date();
        },
        mark() {
            return this.audioInfo.mark || '没有简介...';
        },
        markShowBtnText() {
            return this.markShow ? '收起' : '展开';
        },
        resources() {
            return this.audioInfo.resources || [];
        },
    },
};
</script>

<style lang="less">
.audio-deatail__module {
  .audio-detail__wrapper {
    min-height: 400px;
    margin-bottom: 20px;
    padding: 20px;
    display: flex;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    background: #000 url("~@/assets/bannerModule_bg.png") -0.5px;
    background-size: 50px;
    color: #fff;
  }
  .audio-detail__wrapper:hover .audio-cover__item {
    border-color: @base_color_2;
    box-shadow: -5px 5px 0px @base_color;
  }
  .audio-bg__item {
    max-width: initial;
    max-height: initial;
    width: 110%;
    height: 110%;
    position: absolute;
    top: -5%;
    left: -5%;
    filter: blur(4px);
    object-fit: cover;
    opacity: 0.7;
    pointer-events: none;
  }
  .audio-cover__item {
    width: 200px;
    height: 200px;
    flex-shrink: 0;
    position: relative;
    object-fit: cover;
    transition: all 0.3s;
    border: 5px solid @base_color;
    box-shadow: 5px -5px 0px @base_color_2;
    pointer-events: none;
  }
  .audio-info__group {
    padding: 0 20px;
    position: relative;
    word-break: break-word;
    .audio-info__item {
      margin-bottom: 15px;
    }
    .audio-title__item {
      font-size: 24px;
      font-weight: bold;
    }
    .audio-classify__group {
      display: flex;
      align-items: center;
    }
    .audio-classify__group .item {
      color: #fff;
    }
    .audio-classify__group .el-icon-arrow-right {
      margin: 0 5px;
    }
  }
  .audio-mark__item {
    max-height: 240px;
    line-height: 18px;
    white-space: pre-line;
    font-size: 12px;
    letter-spacing: 0;
    overflow: hidden;
    &.open {
      max-height: initial;
    }
  }
  .audio-mark-show__btn {
    margin-top: 12px;
    line-height: 18px;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
  }
  @media (max-width: 1400px) {
    .audio-detail__wrapper {
      flex-wrap: wrap;
    }
    .audio-cover__item {
      width: 100%;
      height: auto;
      margin-bottom: 20px;
    }
  }
}
</style>
